python PCL LAS Open3D点云

2023/03/18 23:54:34

VS2019+PCL+LAS点云学习

点云安装

安装教程

    1. CSDN教程等
    1. 1.1 【python3.6】python安装PCL(适用命令行或pycham中)-PCL 1.12.1

    2. https://blog.csdn.net/weixin_44244190/article/details/124324121

  1. 1.

    1. 部分教程
    1. 2.1 点云可视化:mayavi、matplotlib、CloudCompare

    2. https://blog.csdn.net/suiyingy/article/details/124015667

    1. 2.2 点云数据常用处理:数据集增强(仿射变换、添加噪声、下采样、数据标准化)

    2. https://blog.csdn.net/taifyang/article/details/124365265

    1. 2.3 Python点云数据处理

    2. https://www.zhihu.com/column/c_1349368779659575296?utm_id=0

    1. 2.4【点云无损压缩】python-pcl:点云las、laz文件的读取、写入、压缩

    2. https://blog.csdn.net/qq_40985985/article/details/105784220

点云入门

功能示例代码段

  1. 读取点云及基本信息
def readlas():
    with laspy.open('./data/10层3号切片抽稀.las') as fh:
        print('Points from Header:', fh.header.point_count)
        las = fh.read()
        print(las)
        print('Points from data:', len(las.points))
        ground_pts = las.classification == 2
        bins, counts = np.unique(las.return_number[ground_pts], return_counts=True)
        print('Ground Point Return Number distribution:')
        for r, c in zip(bins, counts):
            print('{}:{}'.format(r, c))
        print('min: ', fh.header.min)  # x、y、z 的最小值
        print('max: ', fh.header.max)  # x、y、z 的最大值
        print(np.array(las.xyz))
Points from Header: 57185
<LasData(1.2, point fmt: <PointFormat(2, 0 bytes of extra dims)>, 57185 points, 2 vlrs)>
Points from data: 57185
Ground Point Return Number distribution:
min:  [-3.79119968 -6.34900093 -0.05      ]
max:  [ 9.53839999 12.90089989  0.05      ]
  1. 点云格式转换:las->pcd
# 适用于laspy<2.0.0的版本
def getCloud():
    file = r"./data/10层3号切片抽稀.las"
    f = File(file, mode='r')
    inFile = np.vstack((f.x, f.y, f.z, f.intensity)).transpose()
    cloud = pcl.PointCloud_PointXYZI()
    cloud.from_array(np.array(inFile, dtype=np.float32))
    f.close()

    return cloud

# 保存为pcd文件
def save_pcd():
    end1 = time.time()
    cloud = getCloud()
    pcl.save(cloud, r"./data/test.pcd")
    end2 = time.time()
    print("las2pcd 耗时:%.2f秒" % (end2 - end1))
    print('-------endl----------')

知识点

报错